package com.arsl.client;

import java.sql.Date;

import com.arsl.client.data.Content;
import com.arsl.client.data.Edition;
import com.arsl.client.data.PageView;
import com.arsl.client.data.Paper;
import com.arsl.client.data.Section;
import com.arsl.client.data.SectionStats;
import com.arsl.client.data.Tag;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("services")
public interface PaperaziService extends RemoteService {

	Edition[] getEditions(int paperId);

	Section[] getSections(int paperId);

	String viewPageJson(int arPageId);

	PageView viewPage(int arPageId, String auth);

	String getPageImageUrl(int arPageId);

	Content[] getContent(int tagId);

	Tag[] getTags(int arPageId);

	int addPublisher(String name);

	int addUser(String email, String password, int publisherId);

	boolean editPassword(String email, String newPassword);

	int addPaper(int publisherId, String name, String frequency, float height,
			float width);

	/**
	 * Adds a publication to this date and edition if not exists. if exists,
	 * simply return the id of that publication
	 * 
	 * @param paperId
	 * @param publishedDate
	 * @param edition
	 * @return
	 */
	int addPublication(int paperId, Date publishedDate, int editionId);

	/**
	 * 
	 * @param publicationId
	 * @param pageNumber
	 * @param httpSession
	 * @return the UUID embedded in the QR code of the AR Page
	 */
	int addARPage(int publicationId, int sectionId, int pageNumber);

	boolean setARPageImage(int arpageId, String imageUrl);

	boolean removeARPage(int ARPageId);

	int addTag(int ARPageId, float startx, float starty, float height,
			float width);

	boolean removeTag(int tagId);

	boolean editTag(String tagId, float nstartx, float nstarty, float nheight,
			float nwidth);

	/**
	 * Convinience function to add content directly to tag
	 * 
	 * @param tagId
	 * @param contentType
	 * @param title
	 * @param description
	 * @param url
	 * @return
	 */
	int addContent(int tagId, int publisherId, String contentType,
			String title, String description, String url);

	int createContent(int publisherId, String contentType, String title,
			String description, String url);

	boolean addContentToTag(int tagId, int contentId);

	boolean removeContent(int contentId);

	Paper[] getPapers(int publisherId);

	/**
	 * 
	 * @param username
	 * @param password
	 * @param publisher
	 * @return key to be used for this session
	 */
	Integer[] signIn(String username, String password);

	/**
	 * 
	 * @param username
	 * @param publisher
	 * @param key
	 * @return validates whether the key is the correct key for this session for
	 *         this user
	 */
	boolean isLoggedIn(String username, String key);

	Paper getPaperDetails(int paperId);

	int addSection(int paperId, String section);

	int addEdition(int paperId, String edition);

	boolean removeSection(int paperId, String section);

	boolean removeEdition(int paperId, String edition);

	int updateTagContent(int tagId, Content[] contents);

	boolean changeDimensions(int paperId, float width, float height);

	boolean changeTagPlacement(int tagId, float x, float y, float width,
			float height);

	void incHits(int arPageId);

	int getHits(int arPageId);

	SectionStats[] getHitStats(int paperId, Date startDate, Date endDate);
}
